﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DB_Connect
{
    class DatabaseComment
    {
        private DatabaseConnection database;
        private string sqlString;

        public DatabaseComment(DatabaseConnection database, string sql)
        {
            this.database = database;
            SqlString = sql;
        }

        public DatabaseConnection Database
        {
            get
            {
                return this.database;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentException("The value of database is incorrect.");
                }
                this.database = value;
            }
        }


        public string SqlString
        {
            get
            {
                return sqlString;
            }
            set
            {
                if (String.IsNullOrWhiteSpace(value))
                {
                    throw new ArgumentException("Incorrect SQL string.");
                }
                sqlString = value;
            }
        }



        public void Execute()
        {
            this.database.OpenConnection();
            Console.WriteLine("SQL {0} is done.", SqlString);
            this.database.CloseConnection();
        }

    }
}
